<!DOCTYPE html>
<html lang="zh-cn">
    <head>
        <meta charset="UTF-8"/>
        <meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0" />
        <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
        <title>juicer.js模板引擎的使用-子模板嵌套</title>
        <script src="js/juicer-min.js"></script>
    </head>
    <body>
        <h1>juicer.js模板引擎的使用--子模板嵌套</h1>
        <div id="content"></div>
        <script src="//cdn.bootcss.com/jquery/1.10.2/jquery.min.js"></script>
        <script type="text/juicer" id="subTpl">
            I'm sub content, ${name}
        </script>
        <script>
            var tpl = 'Hi, {@include "#subTpl", subData}, End.';

            var html=juicer(tpl, {
                subData: {
                    name: 'juicer'
                }
            });
            console.log('html',html);
            $("#content").html(html);
            //输出 Hi, I'm sub content, juicer, End.
            //或者通过数据引入子模板，下述代码也将会有相同的渲染结果：

            // var tpl = 'Hi, {@include subTpl, subData}, End.';

            // juicer(tpl, {
            //     subTpl: "I'm sub content, ${name}",
            //     subData: {
            //         name: 'juicer'
            //     }
            // });
        </script>
    </body>
</html>